<?php
namespace app\common\model;
use think\Model;

class LotteryGetUser extends Model
{
	
	/**
     * 获取中奖名单
     * @param type $user_id
     * @param type $new_pwd
     * @return type
     */
	public function getList($uid=0,$activity_id,$pageIndex=1,$pageSize=20)
    {
		$model = new self;
		$model = $model->alias('a');
		$model = $model->join('Coupon b ','b.id= a.gift_id');
		if($uid){
			$model = $model->where('uid',$uid);
		}
		$model = $model->where('is_prize',1);
		$model = $model->where('activity_id',$activity_id);
		$model = $model->page($pageIndex,$pageSize);
		$model = $model->field('a.activity_name,a.term_name,a.nickname,a.add_time');
		$model = $model->field('b.name as gift_name');
		$model = $model->field("CONCAT(left(a.phone,3),'****',right(a.phone,4))  as phone_text");
		$model = $model->order("add_time",'desc');
		return $model->select();
    }
	
}
